package com.pzhu.user.domain.dto.converter;

import com.pzhu.user.api.RoleApi;
import com.pzhu.user.domain.ro.RoleCreateRO;
import com.pzhu.user.domain.ro.RoleUpdateRO;
import com.pzhu.user.domain.vo.RoleSearchVO;
import org.mapstruct.*;

@Mapper(
        componentModel = MappingConstants.ComponentModel.SPRING,
        nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
        unmappedTargetPolicy = ReportingPolicy.IGNORE,
        collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)
public interface RoleDtoConverter {

    RoleCreateRO convert(RoleApi.RoleCreateDTO roleDTO);

    RoleUpdateRO convertUpdate(RoleApi.RoleUpdateDTO roleUpdateDTO);

    @Mapping(target = "roleId", source = "id")
    @Mapping(target = "roleName", source = "roleName")
    @Mapping(target = "roleCode", source = "roleCode")
    @Mapping(target = "description", source = "roleDesc")
    @Mapping(target = "createTime", source = "createTime")
    @Mapping(target = "updateTime", source = "updateTime")
    RoleApi.RoleDTO toDTO(RoleSearchVO roleSearchVO);
}